import Vue from 'vue'

const drag = {
  inserted(el, binding) {
    el.onmousedown = function(e) {
      var disx = e.pageX - el.offsetLeft
      var disy = e.pageY - el.offsetTop
      document.onmousemove = function(e) {
        el.style.left = e.pageX - disx + 'px'
        el.style.top = e.pageY - disy + 'px'
      }
      document.onmouseup = function(e) {
        document.onmousemove = document.onmouseup = null
      }
    }
  }
}
const temp = function(Vue) {
  Vue.directive('drag', drag)
}

Vue.use(temp)
